Jupyter notebook主题的设置

最近学了一点Python,而Jupyter notebook是一个交互式笔记本,很多Python的命令可以在其中运行,但jupyter的默认主题与字体不好看,网上搜索了一下,发现可以对其进行更改,GitHub上有相应的教程(https://github.com/dunovank/jupyter-themes),现在把怎么修改Jupyter notebook的主题与字体简单地介绍一下。

第一步:安装主题

切换到python的安装目录,即C:\Anaconda3\Scripts下,用pip安装,如下所示:

1
2
3
4
5
# install jupyterthemes
pip install jupyterthemes
# upgrade to latest version
pip install --upgrade jupyterthemes

第二步:调整juypter notebook的参数

1. 查看主题

直接在cmd命令行下输入jt -l来相看主题,有这些主题:

chesterish
grade3
gruvboxd
gruvboxl
monokai
oceans16
onedork
solarizedd
solarizedl

2. 选择主题

输入jt -t chesterish选择主题,这里我们选择一个chesterish,新建一个文件,输入print ("hello, python!"),如下所示:
mark如果不满意这个主题,想要恢复默认设置,输入jt -r即可。

3. 工具栏设置
输入jt -t chesterish -T -N可以打开工具窗与文件名称,如下所示:
mark

4. 字体设置
设置主题为Roboto Mono为12pt大小,在cmd下输入jt -t chesterish -f roboto -fs 12,再输入jupyter notebook,查看,如下所示:

mark
我觉得比原来默认的字体好看了。

后来都试了一遍,觉得主题,字体比较好,如下所示:
jt -t chesterish -f roboto -fs 12
jupyter notebook

注:可用的字体与主题参数列表

-f 参数 字体名称
anka Anka/Coder
anonymous Anonymous Pro
aurulent Aurulent Sans Mono
bitstream Bitstream Vera Sans Mono
bpmono BPmono
code Code New Roman
consolamono Consolamono
cousine Cousine
dejavu DejaVu Sans Mono
droidmono Droid Sans Mono
fira Fira Mono
firacode Fira Code
generic Generic Mono
hack Hack
hasklig Hasklig
inconsolata Inconsolata-g
inputmono Input Mono
iosevka Iosevka
liberation Liberation Mono
meslo Meslo
office Office Code Pro
oxygen Oxygen Mono
roboto Roboto Mono
saxmono saxMono
source Source Code Pro
sourcemed Source Code Pro Medium
ptmono PT Mono
ubuntu Ubuntu Mono

主题

主题名称
chesterish
grade3
gruvboxd
gruvboxl
monokai
oceans16
onedork
solarizedd
solarizedl

参考资料

https://github.com/dunovank/jupyter-themes